﻿using Class_Entity.ObjectTwo;
using DataAccess.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BussinessObject.ObjectTwo
{
   public class B_Search
    {
       D_Search ex = new D_Search();
       DataTable tb = new DataTable();
       
       public Companies loadCom(int val)
       {
           Companies fx = new Companies();
           tb = ex.loadCompany(val);
           foreach (DataRow dr in tb.Rows)
           {
               fx.COMPANY_CODE = dr["COMPANY_CODE"].ToString();
               fx.COMPANY_NAME = dr["COMPANY_NAME"].ToString();
               fx.COMPANY_PHONE = dr["COMPANY_PHONE"].ToString();
               fx.COMPANY_EMAIL = dr["COMPANY_EMAIL"].ToString();
               fx.DESCRIPTION = dr["DESCRIPTION"].ToString();
               fx.COMPANY_ADDRESS = dr["COMPANY_ADDRESS"].ToString();
           }
           return fx;
       }
       public Cities loadCity(int val)
       {
           Cities gx = new Cities();
           tb = ex.loadCity(val);
           foreach (DataRow dr in tb.Rows)
           {               
               gx.CITY_CODE = dr["CITY_CODE"].ToString();              
               gx.CITY_NAME = dr["CITY_NAME"].ToString();
               gx.DESCRIPTION = dr["DESCRIPTION"].ToString();             
           }
           return gx;
       }
       public Branches loadBran(int val)
       {
           Branches gx = new Branches();
           tb = ex.loadBran(val);
           foreach (DataRow dr in tb.Rows)
           {
               gx.BRANCH_CODE = dr["BRANCH_CODE"].ToString();
               gx.BRANCH_NAME = dr["BRANCH_NAME"].ToString();
               gx.DESCRIPTION = dr["DESCRIPTION"].ToString();
               gx.BRANCH_PHONE = dr["BRANCH_PHONE"].ToString();
               gx.ADDRESS = dr["ADDRESS"].ToString();
               gx.CITY_ID = int.Parse(dr["CITY_ID"].ToString());
               gx.COMPANY_ID = int.Parse(dr["COMPANY_ID"].ToString()); 
           }
           return gx;
       }
    }
}
